using MediatR;
using Medical.ErrorCode;
using Medical.Api.Read.Dto.WmsDto.WmsOutDto;
using Medical.Api.Read.Service.WmsService;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Medical.Api.Read.Application.Command.Wms.WmsLssueCommand;

namespace Medical.Api.Read.Application.Handler.Wms.WmsLssueHandler
{
    /// <summary>
    /// 获取已审批的出库主表列表处理器
    /// </summary>
    public class GetApprovedOutListHandler : IRequestHandler<GetApprovedOutListCommand, ApiResult<List<WmsOutPageDto>>>
    {
        private readonly IWmsService _service;
        public GetApprovedOutListHandler(IWmsService service)
        {
            _service = service;
        }
        public async Task<ApiResult<List<WmsOutPageDto>>> Handle(GetApprovedOutListCommand request, CancellationToken cancellationToken)
        {
            var list = await _service.GetApprovedOutListAsync();
            return new ApiResult<List<WmsOutPageDto>>
            {
                Code = ApiEnums.Success,
                Data = list,
                Msg = "获取成功"
            };
        }
    }
}